package com.qianfeng.job;

import org.quartz.JobKey;
import org.quartz.SchedulerException;
import org.quartz.impl.StdScheduler;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class DemoTest {

    public static void main(String[] args) throws InterruptedException, SchedulerException {
        //实例化IOC容器
        ClassPathXmlApplicationContext ioc = new ClassPathXmlApplicationContext("spring.xml");
        //获取调度器
        StdScheduler scheduler = (StdScheduler) ioc.getBean("scheduler");
        //获取任务
        JobKey jobKey = JobKey.jobKey("job01", "group01");

        Thread.sleep(5000);
        //任务暂停
        scheduler.pauseJob(jobKey);
        //延时三秒之后再恢复
        Thread.sleep(3000);
        //恢复暂停的任务
        scheduler.resumeJob(jobKey);
        //延时三秒之后再删除
        Thread.sleep(3000);

        scheduler.deleteJob(jobKey);

    }
}
